package site.jlopen.controller.modules;

import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import site.jlopen.assets.config.ThreadAuthUser;
import site.jlopen.domain.project.event.KusciaProjectEvent;
import site.jlopen.domain.project.event.KusciaProjectFlowEvent;
import site.jlopen.entity.BaseResponse;
import site.jlopen.entity.req.ProjectReq;
import site.jlopen.entity.vo.project.ProjectInvite;
import site.jlopen.service.BaseService;

@RestController
@RequestMapping("/project")
public class ProjectController extends BaseService{
	
	@PostMapping("/create")
	public BaseResponse<String> create(@RequestBody ProjectReq req) {
		return projectService.create(ThreadAuthUser.id(), req);
	}

	@GetMapping("/list")
	public List<KusciaProjectEvent> list() {
		return projectService.list(ThreadAuthUser.id());
	}

	@GetMapping("/info")
	public KusciaProjectEvent info(Long projectId) {
		return projectService.projectInfo(projectId);
	}

	@GetMapping("/invites")
	public List<ProjectInvite> invites(Long projectId) {
		return projectService.inviteList(projectId);
	}

	@GetMapping("/finish")
	public BaseResponse<String> finish(Long projectId) {
		return projectService.finish(projectId);
	}

	@GetMapping("/invite")
	public BaseResponse<String> changeInvite(Long inviteId) {
		return projectService.changeInvite(inviteId);
	}

	@GetMapping("/clearing")
	public BaseResponse<String> clearing(Long projectId) {
		return projectService.clearing(projectId);
	}

	@GetMapping("/loadFlows")
	public List<KusciaProjectFlowEvent> loadFlows(Long projectId) {
		return projectService.getFlows(projectId);
	}

	@GetMapping("/removeFlow")
	public BaseResponse<String> removeFlow(Long flowId) {
		return projectService.removeFlow(flowId);
	}

	@PostMapping("/saveFlow")
	public BaseResponse<String> saveFlow(Long projectId, String flowTitle) {
		return projectService.saveFlow(projectId, flowTitle);
	}

	@PostMapping("/saveReadData")
	public BaseResponse<String> saveReadData(Long projectId, Long flowId, Long nodeId, Long dataId) {
		return projectService.saveReadData(projectId, flowId, nodeId, dataId);
	}

}
